package 链表;

/**
 * <p>
 * https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list/
 * 给定一个排序链表，删除所有重复的元素，使得每个元素只出现一次。
 * </p>
 *
 * @author AJun
 * @since 2020/8/12
 */
public class _83_删除排序链表中的重复元素 {

    public ListNode deleteDuplicates(ListNode head) {
        ListNode curr = head;
        while (curr != null && curr.next != null) {
            if (curr.next.val == curr.val)
                curr.next = curr.next.next;
            else
                curr = curr.next;
        }
        return head;
    }

}
